/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace ELE.EnterpriseLibrary.Data
{
  /// <summary>
  /// Representation of a mapped SQL query.
  /// </summary>
  public class ObjectStoredProcedure : NamedItem, ICloneable
  {
    private List<ObjectSqlMapping> mappings;
    private List<ObjectStoredProcedureCursor> cursors;
    /// <summary>
    /// Constructor tha tinitializes the identifier of the query.
    /// </summary>
    /// <param name="name"></param>
    public ObjectStoredProcedure(string name) : base(name) { }
    /// <summary>
    /// Associated or referenced mappings
    /// </summary>
    public List<ObjectSqlMapping> Mappings
    {
      get { return mappings; }
      set { mappings = value; }
    }

    /// <summary>
    /// Associated or referenced cursors
    /// </summary>
    public List<ObjectStoredProcedureCursor> Cursors
    {
      get { return cursors; }
      set { cursors = value; }
    }

    #region ICloneable Members
    /// <summary>
    /// Implementation of <see cref="ICloneable.Clone()"/>
    /// </summary>
    /// <returns></returns>
    public object Clone()
    {
      ObjectStoredProcedure query = new ObjectStoredProcedure(this.Name);
      query.Mappings = new List<ObjectSqlMapping>();
      foreach (ObjectSqlMapping map in this.Mappings)
      {
        query.Mappings.Add((ObjectSqlMapping)map.Clone());
      }
      foreach (ObjectStoredProcedureCursor cursor in this.Cursors)
      {
        query.Cursors.Add((ObjectStoredProcedureCursor)cursor.Clone());
      }
      return query;
    }

    #endregion
  }
}

